package com.smec.moblie.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.smec.moblie.R;
import com.smec.moblie.bean.MaintenanceDetailBean;
import com.smec.moblie.crash.ExitAppUtils;

/**
 * 合同号梯号详情
 *
 * Created by sunyubo on 16/2/24.
 */
public class ContractElevatorInfoActivity extends BaseActivity{
    /** SAP梯号 **/
    private TextView textview_ele_contract_no;
    /** 电梯客户梯号 **/
    private TextView textview_ele_local_name;
    /** 创建日期 **/
    private TextView textview_create_date;
    /** 速度宽度编码 **/
    private TextView textview_spdwth_code;
    /** 载重角度 **/
    private TextView textview_wetang_code;
    /** 层站门 **/
    private TextView textview_flrstpgate;
    /** 接口板软件版本 **/
    private TextView textview_adapter_soft_ver;
    /** 接口板类型 **/
    private TextView textview_adapter_type_code;
    /** 电梯通讯协议 **/
    private TextView textview_ele_protocol_code;
    /** 远程监视终端设备端口号 **/
    private TextView textview_device_port_no;
    /** 质监快速识别号 **/
    private TextView textview_gov_quick_no;
    /** 质监设备编号 **/
    private TextView textview_gov_device_no;
    /** 保养合同编号 **/
    private TextView textview_mnt_contract_no;
    /** 订单编号 **/
    private TextView textview_mnt_vbeln_no;
    /** 开始日期 **/
    private TextView textview_begin_date;
    /** 结束日期 **/
    private TextView textview_end_date;
    /** 合同状态 **/
    private TextView textview_sign_status_code;
    /** 保养电梯台数 **/
    private TextView textview_ele_qty;
    /** 服务开始日 **/
    private TextView textview_begin_weekday_code;
    /** 服务结束日 **/
    private TextView textview_end_weekday_code;
    /** 每日开始工作时段 **/
    private TextView textview_begin_daytime;
    /** 每日结束工作时段 **/
    private TextView textview_end_daytime;
    /** 服务间隔天数 **/
    private TextView textview_service_period;
    /** 延长到保养日期 **/
    private TextView textview_extendto_date;
    /** 合同备注 **/
    private TextView textview_contract_comment;
    /** 返回按钮 **/
    private ImageView imageview_back;
    /** 详情类 **/
    private MaintenanceDetailBean maintenanceDetailBean;

    private RelativeLayout rl_title;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    protected void setContentView() {
        setContentView(R.layout.remes_act_contractelevatorinfo);

    }

    @Override
    protected void initView() {
        rl_title = (RelativeLayout)findViewById(R.id.rl_title);
//        PublicControl.setMargins(rl_title, 0, getStatusBarHeight(ContractElevatorInfoActivity.this), 0, 0);

        ExitAppUtils.getInstance().addActivity(this);
        Intent intent = getIntent();
        maintenanceDetailBean = (MaintenanceDetailBean) intent.getSerializableExtra("maintenanceDetail");

        textview_adapter_soft_ver = (TextView) findViewById(R.id.textview_adapter_soft_ver);
        textview_adapter_type_code = (TextView) findViewById(R.id.textview_adapter_type_code);
        textview_begin_date = (TextView) findViewById(R.id.textview_begin_date);
        textview_begin_daytime = (TextView) findViewById(R.id.textview_begin_daytime);
        textview_begin_weekday_code = (TextView) findViewById(R.id.textview_begin_weekday_code);
        textview_contract_comment = (TextView) findViewById(R.id.textview_contract_comment);
        textview_create_date = (TextView) findViewById(R.id.textview_create_date);
        textview_device_port_no = (TextView) findViewById(R.id.textview_device_port_no);
        textview_ele_contract_no = (TextView) findViewById(R.id.textview_ele_contract_no);
        textview_ele_local_name = (TextView) findViewById(R.id.textview_ele_local_name);
        textview_ele_protocol_code = (TextView) findViewById(R.id.textview_ele_protocol_code);
        textview_ele_qty = (TextView) findViewById(R.id.textview_ele_qty);
        textview_end_date = (TextView) findViewById(R.id.textview_end_date);
        textview_end_daytime = (TextView) findViewById(R.id.textview_end_daytime);
        textview_end_weekday_code = (TextView) findViewById(R.id.textview_end_weekday_code);
        textview_extendto_date = (TextView) findViewById(R.id.textview_extendto_date);
        textview_flrstpgate = (TextView) findViewById(R.id.textview_flrstpgate);
        textview_gov_device_no = (TextView) findViewById(R.id.textview_gov_device_no);
        textview_gov_quick_no = (TextView) findViewById(R.id.textview_gov_quick_no);
        textview_mnt_contract_no = (TextView) findViewById(R.id.textview_mnt_contract_no);
        textview_mnt_vbeln_no = (TextView) findViewById(R.id.textview_mnt_vbeln_no);
        textview_service_period = (TextView) findViewById(R.id.textview_service_period);
        textview_sign_status_code = (TextView) findViewById(R.id.textview_sign_status_code);
        textview_spdwth_code = (TextView) findViewById(R.id.textview_spdwth_code);
        textview_wetang_code = (TextView) findViewById(R.id.textview_wetang_code);
        imageview_back = (ImageView) findViewById(R.id.imageview_back);
        imageview_back.setOnClickListener(this);
    }

    @Override
    protected void getData() {

        if(null!=maintenanceDetailBean) {
            textview_adapter_soft_ver.setText(maintenanceDetailBean.getADAPTER_SOFT_VER());
            textview_adapter_type_code.setText(maintenanceDetailBean.getADAPTER_TYPE_CODE());
            textview_begin_date.setText(maintenanceDetailBean.getBEGIN_DATE());
            textview_begin_daytime.setText(maintenanceDetailBean.getBEGIN_DAYTIME());
            textview_begin_weekday_code.setText(maintenanceDetailBean.getBEGIN_WEEKDAY_CODE());
            textview_contract_comment.setText(maintenanceDetailBean.getCONTRACT_COMMENT());
            textview_create_date.setText(maintenanceDetailBean.getCREATE_DATE());
            textview_device_port_no.setText(maintenanceDetailBean.getDEVICE_PORT_NO());
            textview_ele_contract_no.setText(maintenanceDetailBean.getELE_CONTRACT_NO());
            textview_ele_local_name.setText(maintenanceDetailBean.getELE_LOCAL_NAME());
            textview_ele_protocol_code.setText(maintenanceDetailBean.getELE_PROTOCOL_CODE());
            textview_ele_qty.setText(maintenanceDetailBean.getELE_QTY());
            textview_end_date.setText(maintenanceDetailBean.getEND_DATE());
            textview_end_daytime.setText(maintenanceDetailBean.getEND_DAYTIME());
            textview_end_weekday_code.setText(maintenanceDetailBean.getEND_WEEKDAY_CODE());
            textview_extendto_date.setText(maintenanceDetailBean.getEXTENDTO_DATE());
            textview_flrstpgate.setText(maintenanceDetailBean.getFLRSTPGATE());
            textview_gov_device_no.setText(maintenanceDetailBean.getGOV_DEVICE_NO());
            textview_gov_quick_no.setText(maintenanceDetailBean.getGOV_QUICK_NO());
            textview_mnt_contract_no.setText(maintenanceDetailBean.getMnt_Contract_No());
            textview_mnt_vbeln_no.setText(maintenanceDetailBean.getMNT_VBELN_NO());
            textview_service_period.setText(maintenanceDetailBean.getSERVICE_PERIOD());
            textview_sign_status_code.setText(maintenanceDetailBean.getSIGN_STATUS_CODE());
            textview_spdwth_code.setText(maintenanceDetailBean.getSPDWTH_CODE());
            textview_wetang_code.setText(maintenanceDetailBean.getWETANG_CODE());
        }else {
            Toast.makeText(this, "数据存在错误，打开失败", Toast.LENGTH_SHORT).show();

            ContractElevatorInfoActivity.this.finish();

        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.imageview_back:
                ContractElevatorInfoActivity.this.finish();
                break;
            default:
                break;
        }
    }
}
